package lesson2;

public class VolatileStop implements Runnable{

    private static volatile Boolean flag = false;

    @Override
    public void run() {
        int num = 0;
        while(!flag && num < 1000000){
            if(num % 10 == 0 ){
                System.out.println(num + "是10的倍数");
            }
            num ++;
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        VolatileStop volatileStop = new VolatileStop();
        Thread thread = new Thread(volatileStop);
        thread.start();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        flag = true;
    }



}
